/*
 *  CEMenuItemSprite.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_MenuItemSprite_h__
#define __CE_MenuItemSprite_h__

#include "cocos2dx_extentions/labels/CELabelProtocol.h"
#include "cocos2d.h"


namespace cocosext {

#define CE_MENUITEMSPRITE_FADE_IN_TIME 0.15f
#define CE_MENUITEMSPRITE_FADE_OUT_TIME 0.4f

/////////////////////////////////////////////////////
//
/** CEMenuItemSprite 
* Menu which works closly with CEScrollView, which is its ancestor
*/
/////////////////////////////////////////////////////


class CEMenuItemSprite : public cocos2d::CCMenuItemSprite
{
protected:
	CCRGBAProtocol* _pNormalImage;
    CCRGBAProtocol* _pSelectedImage;
    CCRGBAProtocol* _pDisabledImage;

protected:
	CEMenuItemSprite(): _pNormalImage(NULL), _pSelectedImage(NULL), _pDisabledImage(NULL) {;}

public:
    virtual ~CEMenuItemSprite();

    /* Static constructors */
    /** creates a menu item with a normal, selected and disabled image*/
    static CEMenuItemSprite* itemFromNormalSprite(cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite = NULL);
    /** creates a menu item with a normal and selected image with target/selector */
    static CEMenuItemSprite* itemFromNormalSprite(cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler selector);
    /** creates a menu item with a normal,selected  and disabled image with target/selector */
    static CEMenuItemSprite* itemFromNormalSprite(cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler selector);

public:
    /** initializes a menu item with a normal, selected  and disabled image with target/selector */
    bool initFromNormalSprite(cocos2d::CCNode* normalSprite, cocos2d::CCNode* selectedSprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler selector);


public:
	void stopAllAdditionalActions();

	virtual void release(void);
	virtual void retain(void);

	virtual cocos2d::CCAction* runAction(cocos2d::CCAction* action);

//Cocos2d interface
    virtual void selected();
    virtual void unselected();

private:
	void decreaseZOrder();

}; //CEMenuItemSprite

/////////////////////////////////////////////////////
//
/** CEMenuItemSpriteWithText 
* It is a mix of sprite and label menu item
*/
/////////////////////////////////////////////////////


class CEMenuItemSpriteWithText : public CEMenuItemSprite, public CELabelProtocol
{
protected:
	CELabelProtocol* _pNormalLabel;
    CELabelProtocol* _pSelectedLabel;
    CELabelProtocol* _pDisabledLabel;

protected:
	CEMenuItemSpriteWithText(): _pNormalLabel(NULL), _pSelectedLabel(NULL), _pDisabledLabel(NULL) {;}

public:
    virtual ~CEMenuItemSpriteWithText() {;}

    /* Static constructors */
    /** creates a menu item with a normal,selected  and disabled image with target/selector */
    static CEMenuItemSpriteWithText* itemFromNormalSprite(cocos2d::CCNode* normalSpriteWithLabel, CELabelProtocol* pNormalLabel,
							  cocos2d::CCNode* selectedSpriteWithLabel, CELabelProtocol* pSelectedLabel, 
							  cocos2d::CCNode* disabledSpriteWithLabel, CELabelProtocol* pDisabledLabel, 
							  cocos2d::CCObject* target, 
							  cocos2d::SEL_MenuHandler selector);

public:
    /** initializes a menu item with a normal, selected  and disabled image with target/selector */
    bool initFromNormalSprite(cocos2d::CCNode* normalSpriteWithLabel, CELabelProtocol* pNormalLabel,
							  cocos2d::CCNode* selectedSpriteWithLabel, CELabelProtocol* pSelectedLabel, 
							  cocos2d::CCNode* disabledSpriteWithLabel, CELabelProtocol* pDisabledLabel, 
							  cocos2d::CCObject* target, 
							  cocos2d::SEL_MenuHandler selector);


public:
//  CELabelProtocol interface 
virtual void setString(const wchar_t *str);
virtual const wchar_t* getString(void) const;

}; //CEMenuItemSpriteWithText


}; // end namespace cocosext

#endif // __CE_MenuItemSprite_h__
